<template>
  <d2-container>
    <el-form :inline="true" :model="search" class="demo-form-inline" size="mini">
      <el-form-item label="单位名称">
        <el-input v-model="search.user" placeholder="单位名称"></el-input>
      </el-form-item>
      <el-form-item label="委托单编号">
        <el-input v-model="search.user" placeholder="合同编号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="tableData"
      style="width: 100%"
      max-height="400">
      <el-table-column
        fixed
        prop="id"
        label="编号"
        width="150">
      </el-table-column>
      <el-table-column
        prop="name"
        label="登记号"
        width="120">
      </el-table-column>
      <el-table-column
        prop="province"
        label="委托单编号"
        width="120">
      </el-table-column>
      <el-table-column
        prop="city"
        label="委托单位"
        width="120">
      </el-table-column>
      <el-table-column
        prop="address"
        label="器具名称"
        width="300">
      </el-table-column>
      <el-table-column
        prop="zip"
        label="检测单位"
        width="120">
      </el-table-column>
      <el-table-column
        prop="zip"
        label="套数"
        width="120">
      </el-table-column>
      <el-table-column
        prop="zip"
        label="受理日期"
        width="120">
      </el-table-column>
      <el-table-column
        prop="zip"
        label="检测日期"
        width="120">
      </el-table-column>
      <el-table-column
        prop="zip"
        label="合同号"
        width="120">
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="120">
        <template slot-scope="scope">
          <el-button
            @click.native.prevent="handleAssign(scope.$index, scope.row)"
            type="text"
            size="small">
            分配
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="20"
        layout="total, prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose">
      <el-form ref="form" :model="form" label-width="80px" size="mini">
        <el-form-item label="部门">
          <el-select v-model="form.departId" placeholder="请选择部门" @change="departChange()">
            <el-option
              v-for="item in departMentList"
              :key="item.departId"
              :label="item.departName"
              :value=item.departId
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="人员">
          <el-select v-model="form.userId" placeholder="请选择人员">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </d2-container>
</template>
<script>
import api from '@/api'

export default {
  name: 'measure-task-assign',
  created () {
    this.getData()
    this.getDepartMentList()
  },
  methods: {
    handleAssign () {
      this.dialogVisible = true
    },
    departChange () {
      console.log(this.form.departId)
    },
    async getDepartMentList () {
      this.loading = true
      var data = await api.OA_DEPARTMEN_LIST({
        pageNo: 1,
        pageSize: 100
      })
      this.loading = false
      this.departMentList = data.list
    },
    async getData () {
      this.loading = true
      var data = await api.OA_DEPARTMEN_LIST({
        pageNo: 1,
        pageSize: 10
      })
      this.loading = false
      this.count = data.count
      this.tableData = data.list
    },
    handleCurrentChange (val) {
      console.log(`当前页: ${val}`)
    },
    onSubmit () {
      console.log('submit!')
    },
    handleClose (done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done()
        })
        .catch(_ => {
        })
    }
  },
  data () {
    return {
      dialogVisible: false,
      departMentList: [],
      userList: [],
      tableData: [],
      currentPage: 1,
      count: 0,
      search: {

      },
      form: {
        departId: '',
        userId: ''
      }
    }
  }
}
</script>
